// ****************** Data.c *********************

typedef struct{
  char ID:4;
  unsigned short Data:12;
} DataObject;

// **************** Data_PackageObject ***************************
//
//  Packages data into objects
//
// ***************************************************************
int Data_PackageObject(char MSBbyte, LSBbyte, DataObject *package){
  unsigned short temp;
  temp = (MSBbyte&0x0F);
  temp = (temp<<8)|(LSBbyte);
  package.Data = temp;
  package.ID = (MSBbyte&0xF0>>4);
}

// **************** Data_UnpackageObject *************************
//
// Extracts data and id from objects
//
// ***************************************************************
int Data_UnpackageObject(DataObject package, unsigned short *data){
  data = package.Data;
  return package.ID;
}

// ******************* Data_PackageCANPacket *********************
//
// Packages 12bit data and 4bit id into two 8bytes for compatibility
// with CAN transmissions
//
// ***************************************************************
int Data_PackageCANPacket(char id, unsigned short data, char *MSBbyte, char *LSBbyte){
  char temp;
  temp = (id<<4);
  temp = (temp)|((data>>8)&0x0F)
  MSBbyte = temp;
  LSBbyte = data;
}